home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / nos042_s / iface.h < prev    next >
C/C++ Source or Header  |  1994-09-16  |  5KB  |  159 lines

  1. /*
  2.     -----------------------------------------------------
  3.     ATARI Version by David Nash - dnash@chaos.demon.co.uk
  4.  
  5.     hide definition of tag iface 
  6.     -----------------------------------------------------
  7. */
  8.  
  9. #ifndef    _IFACE_H
  10. #define    _IFACE_H
  11.  
  12. #ifndef _CONFIG_H
  13. #include "config.h"
  14. #endif
  15.  
  16. #ifndef _FILTER_H
  17. #include "filter.h"
  18. #endif
  19.  
  20. #ifndef    _GLOBAL_H
  21. #include "global.h"
  22. #endif
  23.  
  24. #ifndef    _MBUF_H
  25. #include "mbuf.h"
  26. #endif
  27.  
  28. #ifndef _PROC_H
  29. #include "proc.h"
  30. #endif
  31.  
  32. /* Interface encapsulation mode table entry. An array of these structures
  33.  * are initialized in config.c with all of the information necessary
  34.  * to attach a device.
  35.  */
  36.  
  37. #ifdef ATARI 
  38. struct iface;    /* ATARI incomplete definition to hide definition of tag iface */
  39. #endif
  40.  
  41. struct iftype {
  42.     char *name;        /* Name of encapsulation technique */
  43.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  44.                 /* Routine to send an IP datagram */
  45.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  46.                 /* Routine to send link packet */
  47.     char *(*format) __ARGS((char *,char *));
  48.                 /* Function that formats addresses */
  49.     int (*scan) __ARGS((char *,char *));
  50.                 /* Reverse of format */
  51.     int type;        /* Type field for network process */
  52.     int hwalen;        /* Length of hardware address, if any */
  53. };
  54. #define    NULLIFT    (struct iftype *)0
  55. extern struct iftype Iftypes[];
  56.  
  57.  
  58. /* Interface control structure */
  59. struct iface {
  60.     struct iface *next;    /* Linked list pointer */
  61.     char *name;        /* Ascii string with interface name */
  62.  
  63.     int32 addr;        /* IP address */
  64.     int32 broadcast;    /* Broadcast address */
  65.     int32 netmask;        /* Network mask */
  66.  
  67.     int16 mtu;        /* Maximum transmission unit size */
  68.  
  69.     int16 flags;        /* Configuration flags */
  70. #define    DATAGRAM_MODE    0    /* Send datagrams in raw link frames */
  71. #define    CONNECT_MODE    1    /* Send datagrams in connected mode */
  72.  
  73.     int16 trace;        /* Trace flags */
  74. #define    IF_TRACE_OUT    0x01    /* Output packets */
  75. #define    IF_TRACE_IN    0x10    /* Packets to me except broadcast */
  76. #define    IF_TRACE_ASCII    0x100    /* Dump packets in ascii */
  77. #define    IF_TRACE_HEX    0x200    /* Dump packets in hex/ascii */
  78. #define    IF_TRACE_NOBC    0x1000    /* Suppress broadcasts */
  79. #define    IF_TRACE_RAW    0x2000    /* Raw dump, if supported */
  80.     char *trfile;        /* Trace file name, if any */
  81.     FILE *trfp;        /* Stream to trace to */
  82.  
  83.     struct iface *forw;    /* Forwarding interface for output, if rx only */
  84.  
  85.     struct proc *rxproc;    /* Receiver process, if any */
  86.     struct proc *txproc;    /* Transmitter process, if any */
  87.     struct proc *supv;    /* Supervisory process, if any */
  88.  
  89. #ifdef FILTER
  90.     /* Filter specifications */
  91.     struct filter *infilter;  /* Inbound filter */
  92.     struct filter *outfilter; /* Outbound filter */
  93. #endif
  94.  
  95.     /* Device dependant */
  96.     int dev;        /* Subdevice number to pass to send */
  97.                 /* To device -- control */
  98.     int32 (*ioctl) __ARGS((struct iface *,int cmd,int set,int32 val));
  99.                 /* From device -- when status changes */
  100.     int (*iostatus) __ARGS((struct iface *,int cmd,int32 val));
  101.                 /* Call before detaching */
  102.     int (*stop) __ARGS((struct iface *));
  103.     char *hwaddr;        /* Device hardware address, if any */
  104.  
  105.     /* Encapsulation dependant */
  106.     void *edv;        /* Pointer to protocol extension block, if any */
  107.     int type;        /* Link header type for phdr */
  108.     int xdev;        /* Associated Slip or Nrs channel, if any */
  109.     struct iftype *iftype;    /* Pointer to appropriate iftype entry */
  110.  
  111.             /* Encapsulate an IP datagram */
  112.     int (*send) __ARGS((struct mbuf *,struct iface *,int32,int,int,int,int));
  113.             /* Encapsulate any link packet */
  114.     int (*output) __ARGS((struct iface *,char *,char *,int16,struct mbuf *));
  115.             /* Send raw packet */
  116.     int (*raw)        __ARGS((struct iface *,struct mbuf *));
  117.             /* Display status */
  118.     void (*show)        __ARGS((struct iface *));
  119.  
  120.     int (*discard)        __ARGS((struct iface *,struct mbuf *));
  121.     int (*echo)        __ARGS((struct iface *,struct mbuf *));
  122.  
  123.     /* Counters */
  124.     int32 ipsndcnt;     /* IP datagrams sent */
  125.     int32 rawsndcnt;    /* Raw packets sent */
  126.     int32 iprecvcnt;    /* IP datagrams received */
  127.     int32 rawrecvcnt;    /* Raw packets received */
  128.     int32 lastsent;        /* Clock time of last send */
  129.     int32 lastrecv;        /* Clock time of last receive */
  130.  
  131.     /* Demand dial */
  132.     int    dial_me;        /* !0 means demand dial */
  133. };
  134. #define    NULLIF    (struct iface *)0
  135. extern struct iface *Ifaces;    /* Head of interface list */
  136. extern struct iface  Loopback;    /* Optional loopback interface */
  137. extern struct iface  Encap;    /* IP-in-IP pseudo interface */
  138.  
  139. /* Header put on front of each packet in input queue */
  140. struct phdr {
  141.     struct iface *iface;
  142.     unsigned short type;    /* Use pktdrvr "class" values */
  143. };
  144. extern char Noipaddr[];
  145. extern struct mbuf *Hopper;
  146.  
  147. /* In iface.c: */
  148. struct iface *if_lookup __ARGS((char *name));
  149. struct iface *ismyaddr __ARGS((int32 addr));
  150. int if_detach __ARGS((struct iface *ifp));
  151. int setencap __ARGS((struct iface *ifp,char *mode));
  152. char *if_name __ARGS((struct iface *ifp,char *comment));
  153. int bitbucket __ARGS((struct iface *ifp,struct mbuf *bp));
  154.  
  155. /* In config.c: */
  156. int net_route __ARGS((struct iface *ifp,int type,struct mbuf *bp));
  157.  
  158. #endif    /* _IFACE_H */
  159.